package Ajax;

import PoJo.Student;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Ajax extends BaseServlet {
    protected void show(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("被调用了");
    }

    protected void proGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        Student student = new Student("郑清波",2);
        Gson gson = new Gson();
        String s = gson.toJson(student);
        resp.getWriter().write(s);
    }
    protected void proPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        Student student = new Student("刘湖东",3);
        Gson gson = new Gson();
        String s = gson.toJson(student);
        resp.getWriter().write(s);
    }
    protected void proJson(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        Student student = new Student("刘湖东",3);
        Gson gson = new Gson();
        String s = gson.toJson(student);
        resp.getWriter().write(s);
    }
    protected void seariaz(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        Student student = new Student("刘湖东1",4);
        Gson gson = new Gson();
        String s = gson.toJson(student);
        resp.getWriter().write(s);
    }
}